package com.epro.dx.enable;

import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.epro.dx.R;
import com.epro.dx.indicator.IconPagerAdapter;

public class MyViewPagerAdapter extends FragmentPagerAdapter implements IconPagerAdapter
{
	private List<Fragment> fragmentsList;

	private int[] icons;
	
	public MyViewPagerAdapter(FragmentManager fm)
	{
		super(fm);
	}

	public MyViewPagerAdapter(FragmentManager fm, List<Fragment> fragments,boolean isHomeFragment)
	{
		super(fm);
		this.fragmentsList = fragments;
		icons = new int[fragments.size()];
		for (int i = 0; i < fragments.size(); i++)
		{
			if(isHomeFragment){
				icons[i] = R.drawable.index_icon_selector_first_page;
			}else{
				icons[i] = R.drawable.index_icon_selector;
			}
		}
	}

	@Override
	public Fragment getItem(int arg0)
	{
		return fragmentsList.get(arg0);
	}
	
	@Override
	public int getCount()
	{
		return fragmentsList.size();
	}

	@Override
	public int getItemPosition(Object object)
	{
		//return super.getItemPosition(object);
		 return POSITION_NONE;
	}

	@Override
	public int getIconResId(int index)
	{
		return icons[index % icons.length];
	}

	@Override
	public int getIconCount() {
		return fragmentsList.size();
	}
	
}
